<template>
    <el-row class="bc-fff">
        <el-col>
            <el-button  @click="handle(item)" type="primary"  class="mv-20" v-for="  item in package" size="large" :key="Math.random()">{{item.label}}</el-button>
        </el-col>
    </el-row>

</template>

<script>
    export default {
        props: ["package", "event"],
        created() {
            console.log(this.package)
        },
        methods: {
            handle(val) {
                switch (val.type) {
                    case 'to' :
                        this.$router.push({path: val.value})
                        break;
                    case 'affirm' :
                        this.affirm(val, row)
                        break;
                    case 'dialog':
                        this.showDialog(val, row)
                    default:
                }
            },
            affirm(val, row) {
                const {id} = row
                this.$confirm(val.value, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(async () => {
                    console.log(this.api[val.url.module][val.url.value])
                    const res = await this.http[val.url.method](this.api[val.url.module][val.url.value], {id})
                    if (res.code == 200) {
                        this.$message({
                            type: 'success',
                            message: '成功'
                        });
                        this.getList()
                    }
                    else {
                        this.$message.error(res.message)

                    }
                }).catch(() => {

                });
            },


        }
    }
</script>

<style scoped>
    .bc-fff {
        background: #fff;
        padding: 15px 0;
    }

    .mv-20 {
        margin: 0 20px;
    }
</style>
